package com.atguigu.servlet;

import com.atguigu.bean.User;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * Date:2020/9/8
 * Author:ybc
 * Description:
 */
public class TestServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter writer = response.getWriter();
        List<User> list = new ArrayList<>();
        list.add(new User(1,"admin","123","123@qq.com"));
        list.add(new User(2,"admin","123","123@qq.com"));
        list.add(new User(3,"admin","123","123@qq.com"));
        list.add(new User(4,"admin","123","123@qq.com"));
        list.add(new User(5,"admin","123","123@qq.com"));
        for (User user : list) {
            writer.print(user);
        }
    }
}
